package me.croute.calendarexample.asynctask;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;

import me.croute.calendarexample.activity.GVCalendarActivity;
import me.croute.calendarexample.activity.GVCalendarSettingsActivity;
import android.util.Log;

import com.google.api.services.calendar.Calendar.Calendars;
import com.google.api.services.calendar.model.Calendar;
import com.google.api.services.calendar.model.CalendarList;
import com.google.api.services.calendar.model.Event;
import com.google.api.services.calendar.model.Events;

public class GVCalendarEventsTask extends GVCalendarAsyncTasks {

	private static final String TAG = "GVCalendarEventsTask";
	private String CalendarID;
	
	java.util.List<Event> arrayevents = new ArrayList<Event>();
	MethodTypes mTypes;
	Date currentCalendarDate;
	
	public GVCalendarEventsTask(GVCalendarSettingsActivity activity) {
		super(activity);
		// TODO Auto-generated constructor stub
	}

	@Override
	protected void doInBackground() throws IOException {
		// TODO Auto-generated method stub
		Log.d(TAG, "doInBackground - CalendarID : " + CalendarID);
		CalendarList calendarlist = null;
		Events events = null;
		boolean isCalendar = false;
		switch (mTypes) {
		case List: // load events list current calendar
			events = gvClient.events().list(CalendarID).execute();
			// events = gvClient.events().list("primary").execute();
			
			arrayevents = events.getItems(); // get the event lists
			for (Event event : events.getItems()) {
				// System.out.println("event : " + event.getSummary());
				Log.d(TAG, "event : " + event.getSummary());
			}
			String pageToken = events.getNextPageToken();
			if (pageToken != null && !pageToken.isEmpty()) {
				events = gvClient.events().list(CalendarID).setPageToken(pageToken).execute();
			} else {
				
				break;
			}
			break;

		case Input:
				break;
				
		case Get:
			break;
			
		case Delete:
			break;
					

		default:
			break;
		}

		

	}

	@Override
	protected void onPostExecute(Boolean result) {
		// TODO Auto-generated method stub

		super.onPostExecute(result);
	}


}
